/*
 * @FileName: [LogWrapper.java] 
 * @Package com.bcinfo.upp.log 
 * 
 * 
 * Copyright (c) 2011-2015 BCINFO Technology Limited Com.
 * All rights reserved.
 * 
 * This software is the confidential and proprietary 
 * information of BCINFO Technology Limited Company
 * ("Confidential Information"). You shall not disclose 
 * such Confidential Information and shall use it only
 * in accordance with the terms of the contract agreement 
 * you entered into with RKY.
 * 
 * $Rev: 52 $
 * $LastChangedDate: 2013-11-25 11:41:03 +0800 (Mon, 25 Nov 2013) $
 * $LastChangedBy: wanggc $
 * 
 * @category bcinfo-
 * @version 1.1
 * @author $Author: wanggc $
 *
 * Change History:[Formatter: author date description] <br/>
 * 1
 * 2
 * 3
*/
package com.bcinfo.iccard.log;

/**
 * Log的Wrapper <br/>
 * <p>
 * Description:<br/>
 * <p>
 * Log实现类的封装，用于屏蔽例外的处理
 * 
 * <p>
 * For Examples <br/>
 * 
 * <PRE>
 *      不建议使用，
 *      请使用LogFactoryUtil创建Log
 *      @see com.bcinfo.alumni.common.log.LogFactoryUtil
 * </PRE>
 * <p>
 */
public class LogWrapper implements Log
{

    private Log _log;

    public LogWrapper(Log log)
    {
        _log = log;
    }

    public void setLog(Log log)
    {
        _log = log;
    }

    public void debug(Object msg)
    {
        try
        {
            _log.debug(msg);
        } catch (Exception e)
        {
            printMsg(msg);
        }
    }

    public void debug(Throwable t)
    {
        try
        {
            _log.debug(t);
        } catch (Exception e)
        {
            printMsg(t.getMessage());
        }
    }

    public void debug(Object msg, Throwable t)
    {
        try
        {
            _log.debug(msg, t);
        } catch (Exception e)
        {
            printMsg(msg);
        }
    }

    public void error(Object msg)
    {
        try
        {
            _log.error(msg);
        } catch (Exception e)
        {
            printMsg(msg);
        }
    }

    public void error(Throwable t)
    {
        try
        {
            _log.error(t);
        } catch (Exception e)
        {
            printMsg(t.getMessage());
        }
    }

    public void error(Object msg, Throwable t)
    {
        try
        {
            _log.error(msg, t);
        } catch (Exception e)
        {
            printMsg(msg);
        }
    }

    public void fatal(Object msg)
    {
        try
        {
            _log.fatal(msg);
        } catch (Exception e)
        {
            printMsg(msg);
        }
    }

    public void fatal(Throwable t)
    {
        try
        {
            _log.fatal(t);
        } catch (Exception e)
        {
            printMsg(t.getMessage());
        }
    }

    public void fatal(Object msg, Throwable t)
    {
        try
        {
            _log.fatal(msg, t);
        } catch (Exception e)
        {
            printMsg(msg);
        }
    }

    public void info(Object msg)
    {
        try
        {
            _log.info(msg);
        } catch (Exception e)
        {
            printMsg(msg);
        }
    }

    public void info(Throwable t)
    {
        try
        {
            _log.info(t);
        } catch (Exception e)
        {
            printMsg(t.getMessage());
        }
    }

    public void info(Object msg, Throwable t)
    {
        try
        {
            _log.info(msg, t);
        } catch (Exception e)
        {
            printMsg(msg);
        }
    }

    public boolean isDebugEnabled()
    {
        return _log.isDebugEnabled();
    }

    public boolean isErrorEnabled()
    {
        return _log.isErrorEnabled();
    }

    public boolean isFatalEnabled()
    {
        return _log.isFatalEnabled();
    }

    public boolean isInfoEnabled()
    {
        return _log.isInfoEnabled();
    }

    public boolean isTraceEnabled()
    {
        return _log.isTraceEnabled();
    }

    public boolean isWarnEnabled()
    {
        return _log.isWarnEnabled();
    }

    public void trace(Object msg)
    {
        try
        {
            _log.trace(msg);
        } catch (Exception e)
        {
            printMsg(msg);
        }
    }

    public void trace(Throwable t)
    {
        try
        {
            _log.trace(t);
        } catch (Exception e)
        {
            printMsg(t.getMessage());
        }
    }

    public void trace(Object msg, Throwable t)
    {
        try
        {
            _log.trace(msg, t);
        } catch (Exception e)
        {
            printMsg(msg);
        }
    }

    public void warn(Object msg)
    {
        try
        {
            _log.warn(msg);
        } catch (Exception e)
        {
            printMsg(msg);
        }
    }

    public void warn(Throwable t)
    {
        try
        {
            _log.warn(t);
        } catch (Exception e)
        {
            printMsg(t.getMessage());
        }
    }

    public void warn(Object msg, Throwable t)
    {
        try
        {
            _log.warn(msg, t);
        } catch (Exception e)
        {
            printMsg(msg);
        }
    }

    protected void printMsg(Object msg)
    {
        System.err.println(msg);
    }

}
